class Solution
{
public:
    vector<int> inventoryManagement(vector<int>& stock, int k)
    {
        if (stock.empty() || k == 0) return {};
        vector<int> res(k);
        priority_queue<int> max_heap;

        for (int i = 0; i < k; i++)
            max_heap.push(stock[i]);
        for (int i = k; i < stock.size(); i++)
        {
            if (stock[i] < max_heap.top())
            {
                max_heap.pop();
                max_heap.push(stock[i]);
            }
        }
        for (int i = 0; i < k; i++)
        {
            res[i] = max_heap.top();
            max_heap.pop();
        }

        return res;
    }
};